# Maintainer: David Runge <dvzrv@archlinux.org>

_name=django-mailman3
pkgname=python-django-mailman3
pkgver=1.3.9
_commit=37b1ab762440d66eaf501beedd5c7d0c83e213a7  # refs/tags/1.3.9
pkgrel=2
pkgdesc="Libraries and templates to Django-based interfaces interacting with Mailman"
arch=(any)
url="https://gitlab.com/mailman/django-mailman3"
license=(GPL3)
depends=(python-django python-django-allauth python-django-gravatar
python-mailmanclient python-pytz)
makedepends=(git python-build python-installer python-setuptools python-wheel)
checkdepends=(python-pytest)
source=(git+https://gitlab.com/mailman/django-mailman3#tag=$_commit?signed)
sha512sums=('SKIP')
b2sums=('SKIP')
validpgpkeys=('541EA0448453394FF77A0ECC9D9B2BA061D0A67C') # Abhilash Raj <raj.abhilash1@gmail.com>

pkgver() {
  cd $_name
  git describe | sed 's/\([^-]*-g\)/r\1/;s/v//g;s/-/./g'
}

build() {
  cd $_name
  python -m build --wheel --no-isolation
}

check() {
  cd $_name
  export PYTHONPATH="build:$PYTHONPATH"
  django-admin test --settings=django_mailman3.tests.settings_test django_mailman3
}

package() {
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 README.rst -t "$pkgdir/usr/share/doc/$pkgname"
}
